home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / WINER.ZIP / CHAP10-2.BAS < prev    next >
BASIC Source File  |  1992-05-13  |  1KB  |  44 lines

  1. '********** CHAP10-2.BAS - modifies the printer timeout values
  2.  
  3. 'Copyright (c) 1992 Ethan Winer
  4.  
  5. DEFINT A-Z
  6. DECLARE SUB INTERRUPT (IntNo, InRegs AS ANY, OutRegs AS ANY)
  7. DECLARE FUNCTION LPTReady% (LPTNumber)
  8.  
  9. '$INCLUDE: 'REGTYPE.BI'
  10.  
  11. LPTNumber = 1
  12.  
  13. IF LPTReady%(LPTNumber) THEN
  14.   PRINT "The printer is on-line and ready to go."
  15. ELSE
  16.   PRINT "Sorry, the printer is not available."
  17. END IF
  18.  
  19. FUNCTION LPTReady% (LPTNumber) STATIC
  20.  
  21.   DIM Regs AS RegType                'for CALL INTERRUPT
  22.   LPTReady% = 0                      'assume not ready
  23.  
  24.   Address = &H477 + LPTNumber        'LPT timeout address
  25.   DEF SEG = 0                        'access segment zero
  26.   OldValue = PEEK(Address)           'save current setting
  27.   POKE Address, 1                    '1 retry
  28.  
  29.   Regs.AX = 32                       'first print a space
  30.   Regs.DX = LPTNumber - 1            'convert to 0-based
  31.   CALL INTERRUPT(&H17, Regs, Regs)   'print the space
  32.   
  33.   Result = (Regs.AX \ 256) OR 128    'get AH, ignore busy
  34.   Result = Result AND 191            'and acknowledge
  35.   IF Result = 144 THEN               'it worked!
  36.     Regs.AX = 8                      'print a backspace
  37.     CALL INTERRUPT(&H17, Regs, Regs) '  to undo CHR$(32)
  38.     LPTReady% = -1                   'return success
  39.   END IF
  40.  
  41.   POKE Address, OldValue             'restore original
  42.                                      '  timeout value
  43. END FUNCTION
  44.